package com.zy.serivice.impl;

import com.zy.bean.TRolePermission;
import com.zy.bean.TRolePermissionExample;
import com.zy.mapper.TRolePermissionMapper;
import com.zy.service.TRolePermissionService;
import com.zy.util.Datas;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zy 690748807@qq.com
 * @Description: TODO
 * @Date: 2024/1/20 15:07
 * @Version: 1.0
 * @name 方法名字：
 */
@Service
public class TRolePermissionServiceImpl implements TRolePermissionService {
    @Autowired
    TRolePermissionMapper tRolePermissionMapper;

    @Override
    public int savePermissionToRole(Integer roleId, Datas ds) {
        TRolePermissionExample example = new TRolePermissionExample();
        example.createCriteria().andRoleidEqualTo(roleId);
        //保存前需要删除该用户的所有操作权限在重新添加
        tRolePermissionMapper.deleteByExample(example);
        return tRolePermissionMapper.savePermissionToRole(roleId, ds);
    }

    @Override
    public List<Integer> listPermissionIdByRoleId(Integer roleId) {
        List<Integer> tRolePermissions = tRolePermissionMapper.listPermissionIdByRoleId(roleId);
        return tRolePermissions;
    }
}
